//
//  XueGuodeController.m
//  GuShiNews
//
//  Created by 丁一 on 2019/8/24.
//  Copyright © 2019 Jones. All rights reserved.
//

#import "XueGuodeController.h"
#import "XueXiModel.h"
#import "LearnModel.h"
#import "XuexiListViewModel.h"
#import "XXiListCell.h"
#import "XueInfoController.h"
#import "JoneCunChu.h"
#import "MementoCenter.h"
#import "NSObject+MementoCenter.h"

@interface XueGuodeController ()

@end

@implementation XueGuodeController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title=@"学习过的";
    self.Data_array=[NSMutableArray new];
    [self.view addSubview:self.TableView];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    JoneCunChu *shuju=[[JoneCunChu alloc] init];
    
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"XuexiArray"]) {
        [shuju recoverFormStateWithKey:@"XuexiArray"];
        self.Data_array = shuju.JoneArray;
    }
    
    [self.TableView reloadData];
}

#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.Data_array.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return nil;
}

#pragma mark - UITableView DataSource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    XueXiModel *modeld = [self.Data_array objectAtIndex:indexPath.row];
    XXiListCell *cell = [XXiListCell cellForTableView:tableView cellForRowAtIndexPath:indexPath];
    cell.Model = modeld;
    cell.Img.hidden = YES;
    cell.Label_o.text = [JonesClass timeZhuan:modeld.x_date];
    return cell;
}

#pragma mark - UITableView Delegate

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    //    NewsModel *model = [self.Data_array objectAtIndex:indexPath.row];
    return 140;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    XueXiModel *modeld = [self.Data_array objectAtIndex:indexPath.row];
    
    XueInfoController *vc = [XueInfoController new];
    vc.Model = modeld;
    [self.navigationController pushViewController:vc
                                         animated:YES];
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}


@end
